import apis from "@/api/apis.js"

export default{
	namespaced: true,
	state:{
		status:false,
		card:[], ///银行卡信息
	},
	mutations:{
		///是否有银行卡
		status(state,newData){
			if(newData.code==200){
				state.status=true
			}
		},
		///保存银行卡信息
		bankcardData(state,newData){
			state.card=newData
		}
	},
	actions:{
		//添加银行卡
		async getBankCard(context,newData){
			const data = await apis.bankcard.addBankcard(newData)
			context.commit('status',data)
		},
		
		///余额充值
		async addbalance(context,newData){
			const data = await apis.bankcard.addBalance(newData)
			return data
		},
		
		///绑定银行卡
		async bindingcard(context,newData){
			const data = await apis.bankcard.bindingCard(newData)
			return data
		},
		
		///查询获取银行卡信息
		async queryCardData(context,newData){
			const data = await apis.bankcard.queryCard(newData)
			// console.log(data);
			context.commit('status',data)
			context.commit('bankcardData',data.data.list)
		},
		
		///删除银行卡
		async deleteCardData(context,newData){
			const data = await apis.bankcard.deleteCard(newData)
			return data
		},
		
		///余额提现到银行卡
		async WithdrawalCard(context,newData){
			const data = await apis.bankcard.Withdrawal(newData)
			return data
		}
		
	}
}